package com.repast.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.repast.common.Const;
import com.repast.common.ServerResponse;
import com.repast.dao.OpinionMapper;
import com.repast.pojo.Opinion;
import com.repast.service.IOpinionService;
import com.repast.utils.DateUtils;

@Service
public class OpinionServiceImpl implements IOpinionService {
	
	@Autowired
	private OpinionMapper opinionMapper;
	
	public ServerResponse submitOpinion(Opinion opinion) {
		//插入创建时间和更新时间
		String time = DateUtils.formatDateTime(new Date(), "long");
		opinion.setOpinionCreateTime(time);
		opinion.setOpinionUpdateTime(time);
		int insertOpinion = opinionMapper.insert(opinion);
		if(insertOpinion==0){
			return ServerResponse.createByErrorCodeMessage(Const.SUBMIT_OPINION_FAIL, "提交意见反馈失败");
		}
		return ServerResponse.createBySuccess();
	}

}
